﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;

namespace GDIT.BLL
{
    public class SeesionBase : IDisposable
    {
        //供继承的业务逻辑的各种方法，函数使用。
        public Session OnlineFrameWorkSession = null;

        private bool disposedValue = false; //检查冗余

        public void Dispose()//bool disposing)
        {
            if (!this.disposedValue)
            {
                //if (disposing)
                //{
                    //释放其他状态（托管对象）
                    OnlineFrameWorkSession.Disposed += new EventHandler(OnlineFrameWorkSession_Disposed);
                //}
                //释放您自己的状态（非托管对象）
                //将大型字段设置为null;
            }
            disposedValue = true;
        }

        void OnlineFrameWorkSession_Disposed(object sender, EventArgs e)
        {
            Dispose();//true);
            GC.SuppressFinalize(this);
        }

        public Session DataSessionProvider()
        {
            Session DataSession = new Session (XpoDefault.DataLayer);
            //DataSession.Disconnect();
            //DataSession.ConnectionString = MSSqlConnectionProvider.GetConnectionString("localhost","sa","sa","GDIT");
            //DataSession.AutoCreateOption = AutoCreateOption.DatabaseAndSchema;
            return DataSession;
        }
    }
}
